/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * conf_server2.java
 *
 * Created on 3/09/2011, 12:30:07 AM
 */
package serverconf;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Montu
 */
public class conf_server2 extends javax.swing.JFrame {

    /** Creates new form conf_server2 */
    public conf_server2() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        L_NomServidor = new javax.swing.JLabel();
        T_NomServidor = new javax.swing.JTextField();
        L_NomUser = new javax.swing.JLabel();
        T_NomUser = new javax.swing.JTextField();
        L_Pass = new javax.swing.JLabel();
        L_ConfPass = new javax.swing.JLabel();
        T_Pass = new javax.swing.JPasswordField();
        T_ConfPass = new javax.swing.JPasswordField();
        jLabel5 = new javax.swing.JLabel();
        B_ConfServidor = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bufete.BufeteApp.class).getContext().getResourceMap(conf_server2.class);
        L_NomServidor.setFont(resourceMap.getFont("L_Pass.font")); // NOI18N
        L_NomServidor.setText(resourceMap.getString("L_NomServidor.text")); // NOI18N
        L_NomServidor.setName("L_NomServidor"); // NOI18N

        T_NomServidor.setText(resourceMap.getString("T_NomServidor.text")); // NOI18N
        T_NomServidor.setName("T_NomServidor"); // NOI18N

        L_NomUser.setFont(resourceMap.getFont("L_Pass.font")); // NOI18N
        L_NomUser.setText(resourceMap.getString("L_NomUser.text")); // NOI18N
        L_NomUser.setName("L_NomUser"); // NOI18N

        T_NomUser.setText(resourceMap.getString("T_NomUser.text")); // NOI18N
        T_NomUser.setName("T_NomUser"); // NOI18N

        L_Pass.setFont(resourceMap.getFont("L_Pass.font")); // NOI18N
        L_Pass.setText(resourceMap.getString("L_Pass.text")); // NOI18N
        L_Pass.setName("L_Pass"); // NOI18N

        L_ConfPass.setFont(resourceMap.getFont("L_Pass.font")); // NOI18N
        L_ConfPass.setText(resourceMap.getString("L_ConfPass.text")); // NOI18N
        L_ConfPass.setName("L_ConfPass"); // NOI18N

        T_Pass.setText(resourceMap.getString("T_Pass.text")); // NOI18N
        T_Pass.setName("T_Pass"); // NOI18N

        T_ConfPass.setText(resourceMap.getString("T_ConfPass.text")); // NOI18N
        T_ConfPass.setName("T_ConfPass"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("L_Pass.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        B_ConfServidor.setText(resourceMap.getString("B_ConfServidor.text")); // NOI18N
        B_ConfServidor.setName("B_ConfServidor"); // NOI18N
        B_ConfServidor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B_ConfServidorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(L_Pass)
                            .addComponent(L_NomUser)
                            .addComponent(L_ConfPass)
                            .addComponent(L_NomServidor))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(T_ConfPass)
                            .addComponent(T_Pass)
                            .addComponent(T_NomUser)
                            .addComponent(T_NomServidor, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jLabel5)))
                .addContainerGap(40, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(249, Short.MAX_VALUE)
                .addComponent(B_ConfServidor, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(216, 216, 216))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addComponent(jLabel5)
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(L_NomServidor)
                    .addComponent(T_NomServidor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(L_NomUser)
                    .addComponent(T_NomUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(L_Pass)
                    .addComponent(T_Pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(L_ConfPass)
                    .addComponent(T_ConfPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addComponent(B_ConfServidor, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void B_ConfServidorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_ConfServidorActionPerformed
        // TODO add your handling code here:
        String nombre_server= "";
        String Password="";
        String User = "";
       
        if (T_Pass.getText().equals(T_ConfPass.getText())){
            
            Password=T_ConfPass.getText();
            nombre_server=T_NomServidor.getText();
            User = T_NomUser.getText();
            LeerArchivodeConexion escribir = new LeerArchivodeConexion();   
            try {
                escribir.EscribirArchivo(nombre_server,Password,User);
            } catch (IOException ex) {
                Logger.getLogger(conf_server.class.getName()).log(Level.SEVERE, null, ex);
            }
            JOptionPane.showMessageDialog(null, "El archivo de configuracion se ha modificado!");
            
            
        }else {JOptionPane.showMessageDialog(null, "Las contraseñas no coinciden! vuelva a intentarlo");}
        T_NomServidor.setText("");
        T_NomUser.setText("");
        T_Pass.setText("");
        T_ConfPass.setText("");
    }//GEN-LAST:event_B_ConfServidorActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new conf_server2().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton B_ConfServidor;
    private javax.swing.JLabel L_ConfPass;
    private javax.swing.JLabel L_NomServidor;
    private javax.swing.JLabel L_NomUser;
    private javax.swing.JLabel L_Pass;
    private javax.swing.JPasswordField T_ConfPass;
    private javax.swing.JTextField T_NomServidor;
    private javax.swing.JTextField T_NomUser;
    private javax.swing.JPasswordField T_Pass;
    private javax.swing.JLabel jLabel5;
    // End of variables declaration//GEN-END:variables
}
